package org.hqmdev.singleton;

/**
 * Static Block Singleton
 * Advantage: providing exception handling
 * Drawback: same as EagerInitializationSingleton
 * @author hqm2zxy
 *
 */
public class StaticBlockSingleton {
	
	private static StaticBlockSingleton instance;
	
	private StaticBlockSingleton() {}
	
	//static block initialization for exception handling
	static {
		try {
			instance = new StaticBlockSingleton();
		} catch (Exception e) {
			throw new RuntimeException("Exception occured "
					+ "in creating singleton instance");
		}
	}
	
	public static StaticBlockSingleton getInstance() {
		return instance;
	}
}
